﻿Imports System
Imports System.Collections.Generic
Imports System.IO.Ports

Public Class ComPortUtilities


    ''' <summary>
    ''' Hàm lấy về tất cả các cổng Com tồn tại trong máy tính
    ''' </summary>
    ''' <returns>Danh sách cổng COM</returns>
    Public Shared Function GetAllSerialPort() As List(Of String)
        Dim result As List(Of String) = New List(Of String)()
        Try
            Dim ports() As String = SerialPort.GetPortNames
            For Each port As String In ports
                result.Add(port)
            Next
            Return result
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

End Class
